home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / 640x480.pas < prev    next >
Pascal/Delphi Source File  |  1994-04-26  |  2KB  |  79 lines

  1.  
  2. {$g+}
  3. program test640x480x16; { mode 12h }
  4. { Mode 12h putpixel-routine, by Bas van Gaalen, Holland, PD }
  5. uses crt;
  6. const times:longint=50000; {sega000:word=$a000;}
  7. var time:longint absolute $0:$46c; time1,time2,endtime1,endtime2:longint;
  8.  
  9. procedure setvideo(md:word); assembler; asm
  10.   mov ax,md; int 10h; end;
  11.  
  12. procedure putpixel(x,y:word; c:byte);
  13. var b:byte;
  14. begin
  15.   port[$3c4]:=2; port[$3c5]:=c;
  16.   b:=mem[sega000:y*80+x shr 3];
  17.   mem[sega000:y*80+x shr 3]:=b or (1 shl (7-(x and 7)));
  18. end;
  19.  
  20. procedure asmputpix(x,y:word; c:byte); assembler;
  21. asm
  22.   mov dx,03c4h
  23.   mov al,2
  24.   out dx,al
  25.   inc dx
  26.   mov al,[c]
  27.   out dx,al
  28.  
  29.   mov bx,80
  30.   mov es,sega000
  31.   mov ax,[y]
  32.   mul bx
  33.   mov di,[x]
  34.   shr di,3
  35.   add di,ax
  36.   mov dl,[es:di]
  37.  
  38.   mov ch,[byte(x)]
  39.   and ch,7
  40.   mov cl,7
  41.   sub cl,ch
  42.   mov ch,1
  43.   shl ch,cl
  44.   or dl,ch
  45.   mov [es:di],dl
  46. end;
  47.  
  48. procedure clrgraph; assembler;
  49. asm
  50.   mov dx,03c4h
  51.   mov al,2
  52.   out dx,al
  53.   inc dx
  54.   mov al,15
  55.   out dx,al
  56.   mov es,sega000
  57.   xor di,di
  58.   xor ax,ax
  59.   mov cx,80*480/2
  60.   rep stosw
  61. end;
  62.  
  63. var i:longint;
  64. begin
  65.   setvideo($12);
  66.   randomize;
  67.   time1:=time;
  68.   for i:=1 to times do putpixel(random(640),random(480),random(16));
  69.   endtime1:=time;
  70.   clrgraph;
  71.   time2:=time;
  72.   for i:=1 to times do asmputpix(random(640),random(480),random(16));
  73.   endtime2:=time;
  74.   setvideo(3);
  75.   writeln(times,' pixels in Pas takes ',((endtime1-time1)/18.2):0:2,' sec');
  76.   writeln(times,' pixels in Asm takes ',((endtime2-time2)/18.2):0:2,' sec');
  77.   repeat until keypressed; while keypressed do readkey;
  78. end.
  79.